package net.dlvx.vlex.wx.lasting.service;

import java.util.List;

import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import net.dlvx.vlex.wx.lasting.model.Msg;
import net.dlvx.vlex.wx.lasting.repository.MsgRepository;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;



@Service
@Transactional
public class MsgServiceImpl implements MsgService
{
    @Autowired
    private MsgRepository msgRepository;

    public List<Msg> findAll()
    {
        return msgRepository.findAll();
    }

    public List<Msg> findByName(String name)
    {
        List<Msg> MsgList1 = msgRepository.findAll();
        System.out.println("MsgList1:" + MsgList1);
        return MsgList1;
    }

    public void saveMsg(WxMpXmlMessage book)
    {
        Msg m = new Msg();
        BeanUtils.copyProperties(book, m);
        msgRepository.save(m);
    }

    @Override
    public Msg findOne(long id) {
        return null;
    }

    @Override
    public void delete(long id) {

    }

    public void delete(Msg m)
    {
        msgRepository.delete(m);
    }
}
